package com.huang.mapper;

import com.huang.pojo.Attractions;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface AttractionsMapper {
    long getCount(Object o);

    //查询景点信息的两个方法
    //无参数
    List<Attractions> getAtrList(int startIndex, int pageSize);
    //有参数
    List<Attractions> getAtrList1(String query,int startIndex, int pageSize);

    //景点添加
    void addStr(Object o, String name, String atrinfo, String atrlevel, int num, int price, Boolean status);
    //景点信息状态改变，
    @Update("update attractions set status=#{status} where id=#{id}")
    void update(int id, boolean status);

    //修改景点信息
    @Update("update attractions set name=#{name},atrinfo=#{atrinfo},atrlevel=#{atrlevel},num=#{num}," +
            "price=#{price},status=#{status} where id=#{id}")
    void updateAtr(int id, String name, String atrinfo, String atrlevel, int num, int price, Boolean status);

    //根据景点id删除景点信息
    @Delete("delete from attractions where id=#{id}")
    void deleteStrById(Integer id);

    //用户获取景点信息的
    @Select("select * from attractions")
    List<Attractions> userGetAtrList1();

    @Update("update attractions set num=(num-#{num}) where name=#{name}")
    void updateticketnum(Integer num,String name);
    //查询用户响应购买票的数量
   /* @Select("select num from attractions where name=#{atrname}")
    int getNUm(String atrname);*/
}
